﻿@{
    ViewBag.Title = "Ban quản trị";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

@section JavaScriptCSSImport{
    <link href="@Url.Content("~/Content/mycontent/list_counter.css")" rel="stylesheet" type="text/css"/>
}

@section JavaScriptDocumentReady{
    $('#danhSachThongDiep').jtable({
            tableId: "tableThongDiep",
            title: 'Danh sách các thông điệp',
            pageSize: 20,
            paging: true,
            sorting: true,
            defaultSorting: 'ThoiGianGoi DESC',
            selecting: true, //Enable selecting
            //multiselect: true, //Allow multiple selecting
            //selectingCheckboxes: true, //Show checkboxes on first column
            //selectOnRowClick: false, //Enable this to only select using checkboxes
            actions: {
                listAction: '/Admin/DanhSachThongDiep',
                deleteAction: '/Admin/XoaThongDiep',               
                createAction: '/Admin/ThemThongDiep'
            },          
            fields: {
                ID: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false
                },               
                NguoiGoi : {
                    title: 'Người gửi',                   
                    create: true,
                    edit: true,
                    list: true,
                    options:"/Admin/DanhSachNguoiDung",
                    sorting: false                    
                },
                 NguoihNan : {
                    title: 'Người nhận',                   
                    create: true,
                    edit: true,
                    list: true,
                     options:"/Admin/DanhSachNguoiDung",
                    sorting: false                    
                },
                 EmailNguoiGoi : {
                    title: 'Email người gửi',                   
                    create: true,
                    edit: true,
                    list: true,                     
                    sorting: false                    
                },
                 ChuDe : {
                    title: 'Chủ đề',                    
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                    
                },
                 NoiDung : {
                    title: 'Nội dung',
                     width: '20%',
                    type: 'textarea',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: false,                    
                },
                 ThoiGianGoi: {
                    title: 'Thời gian',
                    type: 'date',
                    displayFormat: 'dd/mm/yy',
                    create: false,
                    edit: false,
                    list: true,
                    sorting: true
                },
                Xoa: {
                    title: 'Trạng thái',
                    create: false,
                    edit: true,
                    list: true,
                    sorting: true,
                    type: 'checkbox',
                    values: { 'false': 'Hoạt động', 'true': 'Bị xóa' },
                },                
            }
        });

        //Load student list from server
        $('#danhSachThongDiep').jtable('load');
        //$('table.jtable').css("table-layout","fixed");

        //Filter
        //Re-load records when user click 'load records' button.
        $('#LoadRecordsButton').click(function (e) {
            e.preventDefault();
            $('#danhSachThondDiep').jtable('load', {
                name: $('#name').val(),
                cityId: $('#cityId').val()
            });
        });
}

<!-- Container for jTable -->
<div id="danhSachThongDiep"></div>